<template>
  <view class="container">
    <z-paging ref="paging" v-model="list" @query="getlist">
      <template #top>
        <view class="header">
          <view class="search-bar">
            <u-search
              shape="round"
              v-model="keyword"
              @custom="search"
              placeholder="搜索教练"
            ></u-search>
            <view class="filter-btn" @click="choose">
              <image src="../../static/sx.png" mode="aspectFit"></image>
            </view>
          </view>
        </view>
      </template>

      <view class="trainer-list">
        <view class="trainer-card" v-for="(item, index) in list" :key="index">
          <view class="card-content">
            <view class="trainer-info">
              <view class="trainer-name">
                <text class="label">教练名称</text>
                <text class="value">{{ item.nickname }}</text>
              </view>
              <view class="stats-container">
                <view class="stat-item">
                  <text class="stat-value">{{ item.planCount }}</text>
                  <text class="stat-label">完成课程计划</text>
                </view>
                <view class="stat-divider"></view>
                <view class="stat-item">
                  <text class="stat-value">
                    {{ item.physicalFitnessCount }}
                  </text>
                  <text class="stat-label">体测数量</text>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </z-paging>

    <l-calendar
      v-model="showDate"
      @change="change"
      :isRange="true"
    ></l-calendar>
  </view>
</template>

<script>
import ZPaging from "../../uni_modules/z-paging/components/z-paging/z-paging.vue";
import { coach } from "@/api/fit";
export default {
  components: { ZPaging },
  data() {
    return {
      showDate: false,
      show: false,
      keyword: "",
      // 枚举类

      // 当前页面参数
      options: { dataType: "all" },
      // 当前标签索引
      curTab: 0,
      // 订单列表数据
      // list: getEmptyPaginateObj(),
      list: [],
      startTime: "",
      endTime: "",
    };
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // 初始化当前选中的标签
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // this.$refs.paging.reload();
  },
  
  /**
   * 生命周期函数--监听页面的卸载
   */
  onUnload() {
    // 卸载全局事件订阅
    uni.$off("syncRefresh");
  },

  methods: {
    choose() {
      this.showDate = true;
    },
    change(e) {
      console.log(e, "eeeeeeeee");
      this.startTime = e.startDate;
      this.endTime = e.endDate;
      this.$refs.paging.reload();
    },

    async getlist(pageNo, pageNum = 10, key) {
      let params = {
        page: pageNo,
        size: pageNum,
        startTime: "2022-10-01" + " 00:00:00",
        endTime: "2023-10-22 00:00:00",
      };
      const res = await coach(params);
      this.$refs.paging.complete(res.data);
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background: #f8f8f8;
}

.header {
  background: #fff;
  padding: 20rpx 30rpx;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 20rpx;

  .filter-btn {
    width: 70rpx;
    height: 70rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;

    &:active {
      transform: scale(0.95);
    }

    image {
      width: 40rpx;
      height: 40rpx;
    }
  }
}

.trainer-list {
  padding: 20rpx;
}

.trainer-card {
  background: #fff;
  border-radius: 20rpx;
  margin-bottom: 20rpx;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);

  &:active {
    transform: translateY(2rpx);
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  }
}

.card-content {
  padding: 30rpx;
}

.trainer-info {
  .trainer-name {
    display: flex;
    align-items: center;
    margin-bottom: 20rpx;

    .label {
      font-size: 26rpx;
      color: #666;
      margin-right: 20rpx;
    }

    .value {
      font-size: 34rpx;
      font-weight: 600;
      color: #333;
    }
  }
}

.stats-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20rpx 0;
  background: #EFEFEF;
  border-radius: 12rpx;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;

  .stat-value {
    font-size: 36rpx;
    font-weight: bold;
    color: #333;
    margin-bottom: 8rpx;
  }

  .stat-label {
    font-size: 24rpx;
    color: #666;
  }
}

.stat-divider {
  width: 2rpx;
  height: 40rpx;
  background: #eee;
}

// 添加3D悬浮效果
.trainer-card {
  &:hover {
    transform: translateY(-2rpx);
    box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.08);
  }
}

// 添加统计数字动画
.stat-value {
  transition: transform 0.3s ease;

  &:hover {
    transform: scale(1.1);
    color: #000;
  }
}
</style>
